<template>
     <view style="height: 100%;margin-top: 100rpx;">
		 <!-- @onPostMessage="load" -->
		 <!-- #ifdef H5 -->
		     <!-- <view class="iconfont icon-xiangzuo" @click="goback()"></view> -->
		     <!-- #endif -->
		<hx-navbar  :back="true" :fixed="false" :color="knavTitleColor" barPlaceholder="hidden"
			 	transparent="auto"></hx-navbar>
		<web-view :src="walletUrl" id="myWebView"  @message="onMessage" ></web-view>  
	</view>

</template>

<script>

	export default {
		data() {
			return {
				walletUrl: ""
			}
		},
		onShow() {
			// uni.redirectTo({
				
			// })
		
		},
		onLoad(options) {
			let url = uni.getStorageSync('sdUrl') ;
			this.walletUrl= url
			// console.log('walletUrl', url)
			//app设置样式
			// #ifdef APP-PLUS
				var height = 0;
				uni.getSystemInfo({
					success: (sysinfo) => {
						height = sysinfo.windowHeight;
					},
					complete: () => {}
				});
				var currentWebview = this.$scope.$getAppWebview();
				setTimeout(function() {
					this.barHeight = plus.navigator.getStatusbarHeight();
					var wv = currentWebview.children()[0];
					wv.setStyle({
						top: this.barHeight,
						height: height - this.barHeight,
						scalable: true,
					})
				}, 500);
			
			 // #endif
		},
	 
		  methods: { 
			  onMessage (event) {
			        // 对从web-view中接收到的消息进行处理
					uni.switchTab({
						url: `/pages/index/index`
					})
			        console.log('收到来自web-view的消息-------：', event)
			        // 将消息发送到uni-app中的事件总线
			     //   EventBus.$emit('messageFromH5', event.detail.data)
			      },
			  //监控url
			  recivePostMessag(e) {
			       console.log('web-view loaded------------', e)
			     //  this.url = e.mp.detail.src	  			
			  },
			  goback() {
			        // #ifdef H5
			        return history.back();
			        // #endif
			        // #ifndef H5
			        return uni.navigateBack({
			          delta: 1,
			        })
			        // #endif
			      },
		
		    onLoad2(e) {
		        console.log('web-view message', e)
		       if (e.url === 'https://shucang.zhongfujiayi.com/wap/#/pages/login/login') {
		         console.log('Webview地址变成了指定的URL，执行回调函数222')
		         uni.reLaunch({
		         url:'/pages/mart/mart'
		         })
		         // 在这里执行回调函数
		       }
		      }
		   }
		  }
</script>

<style>

</style>